package com.sify.templates;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.google.gson.stream.JsonReader;

public class Main {

	public static void main(String[] args) throws JsonSyntaxException, IOException {
		
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		
//		Mibs mib  = gson.fromJson(readFile("/tmp/selectedfalse.json"), Mibs.class);
		String json = readFile("/tmp/selectedfalse.json");
		System.out.println("readfile : " + json);
		Mibs mib  = gson.fromJson(json, Mibs.class);
//		gson.fromJ
		System.out.println(mib);
		System.out.println(gson.toJson(mib));
		
	}
	
	private static String readFile( String file ) throws IOException {
	    BufferedReader reader = new BufferedReader( new FileReader (file));
	    String         line = null;
	    StringBuilder  stringBuilder = new StringBuilder();
	    String         ls = System.getProperty("line.separator");

	    while( ( line = reader.readLine() ) != null ) {
	        stringBuilder.append( line );
	        stringBuilder.append( ls );
	    }
	    return stringBuilder.toString();
	}
}
